#include "basic/log.h"

namespace basic {
/*
/// see: https://github.com/gabime/spdlog
#define SPDLOG_HEADER_ONLY
#include "../external/spdlog/include/spdlog/spdlog.h"
#if 1 /// Jerry:to enable console log or file log
#include "../external/spdlog/include/spdlog/sinks/stdout_color_sinks.h"
auto consoleLog = spdlog::stdout_color_mt("log", spdlog::color_mode::automatic);
#else
#include "../external/spdlog/include/spdlog/sinks/basic_file_sink.h"
auto consoleLog = spdlog::basic_logger_mt("log", "logs/basic-log.txt");
#endif

void gLogSetLevel(ELogLevel lvl) {
  spdlog::set_level(spdlog::level::level_enum(lvl));
}
void gLogSetFormat(dkc fmt) {
  spdlog::set_pattern(fmt);
} /// jerry: gLogSetFormat("%^[%H:%M:%S][%t]-> %v%$");

void gLogDebug(const dkc* args...) { consoleLog->debug(args); }
void gLogInfo(const dkc* args...) { consoleLog->info(args); }
void gLogWarn(const dkc* args...) { consoleLog->warn(args); }
void gLogError(const dkc* args...) { consoleLog->error(args); }
void gLogFatal(const dkc* args...) { consoleLog->critical(args); }
*/

#ifdef DK_PLATFORM_OS_WINDOWS
HANDLE g_consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
BOOL b = GetConsoleScreenBufferInfo(g_consoleHandle, &csbiInfo);
WORD g_oldColorAttrs = csbiInfo.wAttributes;
WORD g_oldConsoleBackgroundColor =
    csbiInfo.wAttributes & ~(FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
#else
#endif
} // namespace basic
